package com.gg.star.contorller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.entity.User;
import com.gg.star.service.StarService;

import helpers.baseservlet.BaseServlet;

@WebServlet("/star/ChangeCountBySidServlet")
public class ChangeCountBySidServlet extends BaseServlet {
	@Autowired
	private StarService starService;
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String   sid=request.getParameter("sid");
		String   key=request.getParameter("key");
		System.out.println(sid);
		System.out.println(key);
		if(key.equals("jian")) {
			starService.changeCountBySid(sid,-1);
			
		}else {
			
			starService.changeCountBySid(sid,1);
		}
		User user=(User) request.getSession().getAttribute("user");
		String uid=user.getUid();
		request.getSession().setAttribute("povos",starService.showAllStarsByUid(uid));
	}

}
